package com.aracky.assess.util;
import com.aracky.assess.constants.ComConstants;
import com.aracky.common.util.JWTUtil;
import com.google.common.collect.Maps;

import com.aracky.assess.outside.StartFlowable;
import com.aracky.common.util.HttpUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author zengzhiping
 * @BelongsPackage com.aracky.assess.util
 * @CreateTime 2022-08-26
 * @Description 流程发起工具类
 */
@Component
public class FlowableUtil {


    @Value("${flowable.server-address}")
    private  String flowIp;


    public void batchStartProcess(List<StartFlowable> flowableList){
        //构造访问url
        String flowableUrl = flowIp+ ComConstants.FLOW.BATCH_START_FLOW;

        //获取当前请求头中的数据
        RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
        HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
        String token = request.getHeader(JWTUtil.header);

        //使用http调用接口
       HttpUtil.sendPostHttp(flowableUrl, flowableList,token);
    }


}
